package models.common.entity;

import java.util.Date;

import javax.persistence.Entity;

import play.db.jpa.Model;

/**融通额度明细表
 *@author xiaojun
 *@version 2017-5-15 下午3:54:11
 */
@Entity
public class t_amount_detail extends Model{

	public t_amount_detail(){};
	
	public t_amount_detail(long commercial_lines_id,String full_name,Date crawl_time,double use_amount,double remaining_amount,int crawl_type,String contract_name_code,double finacing_total_limit){
		this.commercial_lines_id = commercial_lines_id;
		this.full_name = full_name;
		this.crawl_time = crawl_time;
		this.use_amount =  use_amount;
		this.remaining_amount = remaining_amount;
		this.crawl_type = crawl_type;
		this.contract_name_code=contract_name_code;
		this.finacing_total_limit=finacing_total_limit;
		
	};
	

	
	/**额度表id*/
	public long commercial_lines_id;
	/**公司名称*/
	public String full_name;
	/**合同名称与编号*/
	public String contract_name_code;
	/**'融通总额度'*/
    public double finacing_total_limit;
	/**额度变动时间*/
	public Date crawl_time;
	/**使用融通额度**/
	public double use_amount;
	/**融通剩余额度**/
	public double remaining_amount;
	/**变动类型0 数字商票1 挂牌融通2 关联商票 3 确认托收还款*/
	public int crawl_type;
	  /**获取额度变动类型*/
    public CrawlType getType() {
    	CrawlType status = CrawlType.getEnum(this.crawl_type);
		
		return status;
	}
    /**
     * 额度变动类型枚举
     *@author xiaojun
     *@version 2017-5-15 下午4:27:53
     */
	public enum CrawlType {
		
		/**数字商票*/
		DIGITALTICKET(0,"数字商票"),
		/**挂牌融通*/
		LISTEDFINANCING(1,"挂牌融通"),
		/** 关联商票*/
		ASSOCIATEDTICKET(2," 关联商票"),
		/** 确认还款*/
		CONFIRM_PAYMENT(3," 确认还款"),
		/**融通返还*/
		FINANCINGREMAINING(4,"融通返还"),
		/**数字商票撤票拒收*/
		DIGITALTICKET_REMAINING(5,"数字商票撤票拒收返还"),
		;
		/** 状态 */
   		public int code;
   		
   		/** 描述 */
   		public String value;
		private CrawlType(int code, String value){
   			this.code = code;
   			this.value = value;
   		}
   		
   		public static CrawlType getEnum(int code){
   			CrawlType[] bidstatus = CrawlType.values();
   			for(CrawlType income:bidstatus){
   				if(income.code == code){
   					
   					return income;
   				}
   			}
   			
   			return null;
   		}
	}
}
